package vow.gui.renderer;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JList;
import javax.swing.JTextArea;
import javax.swing.ListCellRenderer;

import dispute.NegotiationRoom;
import dispute.NegotiationRoom.NEGOTIATION_STATUS;

public class RoomEntryRenderer extends JTextArea implements ListCellRenderer{

	public RoomEntryRenderer(){
		setOpaque(true);
	}
	
	@Override
	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {
		NegotiationRoom room = (NegotiationRoom) value;
		if(room.getStatus() == NEGOTIATION_STATUS.PENDING){
			setBackground(Color.gray);
		}
		if(room.getStatus() == NEGOTIATION_STATUS.ONGOING){
			setBackground(Color.yellow);
		}
		if(room.getStatus() == NEGOTIATION_STATUS.CLOSED_SUCCESSFUL){
			setBackground(Color.green);
		}
		if(room.getStatus() == NEGOTIATION_STATUS.CLOSED_UNSUCCESSFUL){
			setBackground(Color.red);
		}		
		setText(room.toShortString());
		return this;
	}

}
